home *** CD-ROM | disk | FTP | other *** search
-
- function TransformXML(xml, xslDoc)
- {
- //load the stylesheet as a DOMDocument.
- var xslProc;
-
- //Create SAX writer.
- var xmlWriter = new ActiveXObject("Msxml2.MXXMLWriter.4.0");
-
- var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
-
- //Connect the XSLTemplate object to stylesheet DOMDocument.
- xslt.stylesheet = xslDoc;
-
- //Create XSLT processor using stylesheet for XSL template.
- xslProc = xslt.createProcessor();
-
- //Assign XML sample file as input of the transform() method.
- xslProc.input = xml;
-
- //Use a SAX writer as the output of the transform() method.
- xslProc.output = xmlWriter;
-
- //Do transformation on the sample XML file.
- xslProc.transform();
-
- //Use SAX writer ouptut
- return xmlWriter.output;
- }
-
- function getXsltFile ()
- {
- xsltfile ="";
-
- args = WScript.Arguments;
- if (args.length == 0)
- {
- WScript.Echo("Missing module argument");
- }
- else
- {
- Modules = args(0);
- switch (Modules)
- {
- case "1": xsltfile = "defsbx.xslt"; break;
- case "2": xsltfile = "deffw.xslt"; break;
- case "3": xsltfile = "def.xslt"; break;
- };
- }
- return xsltfile;
- }
- //main program function
- function main()
- {
- //Create XML file as a DOMDocument.
- var xmlSrc = new ActiveXObject("Msxml2.DOMDocument.4.0");
- //Create the stylesheet as a DOMDocument.
- var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
- //Create target XML file as a DOMDocument.
- var xmlTarget = new ActiveXObject("Msxml2.DOMDocument.4.0");
- xslDoc.async = false;
- xmlSrc.async = false;
-
- if (!xmlSrc.load("../fncIDs.xml"))
- {
- WScript.Echo ("Error: fncIDs.xml not found");
- return;
- }
- //get xslt file according argument in script
- xsltfile = getXsltFile();
- if (xsltfile !="")
- {
- //load xslt file
- if (!xslDoc.load(xsltfile))
- {
- WScript.Echo ("Error:", xsltfile," file not found: ");
- return;
- }
- //run transformation to get result xml file
- xmlTarget.loadXML( TransformXML(xmlSrc, xslDoc));
- xmlTarget.save("def.xml");
- }
- }
-
- //script entry point
- main();